﻿@{
    ViewBag.Title = "Notice";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<h2>Notice</h2>
<form id="testForm">
    <div id="testForm">
        <table align="center" style="margin-top:100px">
            <tr>
                <td><input id="File1" type="file" name="fileUp" /></td>
                <td><input type="button" value="上传" onclick="javascript:dian();"></td>
            </tr>
        </table>
    </div>
    @*<div>
            <textarea  id="file" rows="5" cols="150"></textarea>
        </div>*@
</form>
  通知信息：<input id="MessageContent" type="text"/>
<button type="button" class="btn btn-primary btn-lg btn-block" id="btn">发送</button>
<script>

    $(function () {
        $("#btn").click(function () {
            $.ajax({
                type: "get",
                url: "/Home/Uploading_Add",
                data: {
                    
                    MessageContent: $("#MessageContent").val()
                },
               
                success:function (data){
                    if (data > 0) {
                        alert('发送成功！');
                    }
                    else {
                        alert('发送失败！');
                    }
                }
            })
        })
    })
</script>
<script language="javascript" type="text/javascript">
    // alert(document.getElementById("File1").value);
    function dian() {
        if (document.getElementById("File1").value == "") {
            alert("请选择文件");
        }
        else {
            var formData = new FormData(document.getElementById("testForm"));
            $.ajax({
                url: '/Home/upfile',
                type: 'POST',
                data: formData,
                cache: false,
                processData: false,
                contentType: false,
                success: function (returndata) {
                    //$("#file").html(returndata);
                    alert(returndata);
                },
            })
        }

    }
</script>